﻿<?php
include 'config.php';
//include 'indextj.php';
$y=$_GET['y'];
$int=intval($y);
if($int<1){
	$y='1';
}
if($y==''){
	$y='1';
}
$a=postData('https://www.xvideos.com/new/'.$y,'');
$dt=getSubstr($a,'<div class="pagination-with-settings">','<div class="remove-ads">');
$dt=getSubstr($dt,'<div class="mozaique">','<a class="active" href="">');
$dt=str_replace('	','' ,$dt);
$dt=str_replace(array("\r\n", "\r", "\n"), '', $dt);
$dt=str_replace('</div></div><div class="pagination "><ul><li>','' ,$dt);
$dt=str_replace('<div class="thumb-inside">','' ,$dt);
$dt=str_replace('<div class="microthumb">','' ,$dt);
$dt=str_replace('<div class="microthumb-thumb" style="background-position:0% 0%"></div>','' ,$dt);
$dt=str_replace('<div class="microthumb-border">','' ,$dt);
$dt=str_replace('</div></div>','' ,$dt);
$dt=str_replace('<div class="thumb">','' ,$dt);
$dt=str_replace(' class="thumb-block "','' ,$dt);
$dt=str_replace('<div id="','{"vid":"' ,$dt);
$dt=str_replace('"><a href="/video','","url":"'.$http.'/video' ,$dt);
$dt=str_replace('><img src=',',"imggif":' ,$dt);
$dt=str_replace('" data-src="','","img":"' ,$dt);
$dt=str_replace(' data-idcdn=',',"idcdn":' ,$dt);
$dt=str_replace(' data-videoid=',',"videoid":' ,$dt);
$dt=str_replace('" id="','","id":"' ,$dt);
$dt=str_replace('/></a></div>','' ,$dt);
$dt=str_replace('<span class="video-hd-mark">',',"hd":"' ,$dt);
$dt=str_replace('</span></div><p>','"<p>' ,$dt);
$dt=str_replace('<p><a href=',',"url2":' ,$dt);
$dt=str_replace(' title=',',"titel":' ,$dt);
$dt=str_replace('<p class="metadata">','' ,$dt);
$dt=str_replace('<span class="bg">','' ,$dt);
$dt=str_replace('<a href="/profiles','","form":"/profiles' ,$dt);
$dt=str_replace('</a><span>','","vm":"' ,$dt);
$dt=str_replace('</span>- <span class="duration">','","time":"' ,$dt);
$dt=str_replace('xv.thumbs.prepareVideo','' ,$dt);
$dt=str_replace('</span></span></p></div>','"' ,$dt);
$dt=str_replace('<script>',',"xvid":"' ,$dt);
$dt=str_replace('</script>','"}' ,$dt);//-------------------------
$dt=str_replace('</a></p>','' ,$dt);
$dt=str_replace('</div>','' ,$dt);
$dt=str_replace('"><a href="/video','","url":"/video' ,$dt);
$dt=str_replace('class="microthumb-thumb"','' ,$dt);
$dt=str_replace(' style="background-position:','' ,$dt);
$dt=str_replace('"><div ','","tnnd":"' ,$dt);
$dt=str_replace('/></a>','' ,$dt);
$dt=str_replace('</a>','' ,$dt);
$dt=str_replace(' href="/verified/videos">','' ,$dt);
$dt=str_replace('<a class="icon-f icf-check-circle icf-white-fill prof-verified-tick"','' ,$dt);
$dt=str_replace('</span>,"titel"','","titel"' ,$dt);
$dt=str_replace('"titel":"Verified uploader",','' ,$dt);
//$dt=str_replace('<a href=','","zz":' ,$dt);
$dt=str_replace('','' ,$dt);
$dt=str_replace('','' ,$dt);
$dt=str_replace('','' ,$dt);
$dt=str_replace('','' ,$dt);
$dt=str_replace('','' ,$dt);
$dt=str_replace('','' ,$dt);
$dt=str_replace('">','?/' ,$dt);
//-------------------------------------------
$dt=str_replace('}{','},{' ,$dt);
$json='{"data":['.$dt.']}';
$div='<a href='.getSubstr($json,'}<a href=',']}');
$json=str_replace($div,'' ,$json);
$json=str_replace('<a href=','","zz":' ,$json);//2018-4-14  
$json=str_replace('","url":"/video','","url":"'.$http.'/video' ,$json);
echo $json;






























function postData($url, $data)
{
    $headers = array();
    $headers[] = ':authority:api.47ks.com';
    $headers[] = ':method:GET';
    $headers[] = ':path:/webcloud/?v=http://www.iqiyi.com/v_19rr7qhfg0.html';
    $headers[] = ':scheme:https';
    $headers[] = 'accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
    $headers[] = 'accept-encoding:gzip, deflate, sdch, br';
    $headers[] = 'accept-language:zh-CN,zh;q=0.8';
    $headers[] = 'referer:http://www.paload.cn/?url=http://www.iqiyi.com/v_19rr7qhfg0.html';
    $headers[] = 'upgrade-insecure-requests:1';
    $headers[] = 'user-agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36';
    $ch = curl_init();
    $timeout = 300;
    curl_setopt($ch, CURLOPT_URL, $url);
    //curl_setopt($ch, CURLOPT_REFERER, "http://127.0.0.1/");   //构造来路
	//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//构造http协议头
	
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);    // https请求 不验证证书和hosts
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $handles = curl_exec($ch);
    curl_close($ch);
    return $handles;
}
/*以下是取中间文本的函数 
getSubstr=调用名称
$str=预取全文本 
$leftStr=左边文本
$rightStr=右边文本
*/
function getSubstr($str, $leftStr, $rightStr)
{
    $left = strpos($str, $leftStr);
    //echo '左边:'.$left;
    $right = strpos($str, $rightStr,$left);
    //echo '<br>右边:'.$right;
    if($left < 0 or $right < $left) return '';
    return substr($str, $left + strlen($leftStr), $right-$left-strlen($leftStr));
}
?>